<!--
 * @Description: 重定向
 * @Author: chenju
 * @Date: 2022-01-26 17:43:45
 * @LastEditors: qingyang
 * @LastEditTime: 2022-12-05 16:15:00
-->
<template>
  <div></div>
</template>
<script lang="ts">
import { store } from '@/store';
import { defineComponent } from 'vue';
import { useRouter } from 'vue-router';
export default defineComponent({
  name: 'Redirect',
  setup() {
    const router = useRouter();
    const menuList = store.state.user.menuList;
    // 获取可访问的path列表
    const menuPathList = [...new Set(menuList.map(item => item.redirect || item.path))];
    if (menuPathList && menuPathList.length) {
      router.replace(menuPathList[0] || '/workbench');
    } else {
      router.push(`/401?url=redirect`);
    }
  }
});
</script>
